Central Article

The mDialogBox Component: Not Your Father's Dialog Box


Table of Contents

  1. Introduction
  2. Understanding the mDialogBox Structure
  3. Putting mDialogBox to Work
  4. mDialogBox Tips

mDialogBox Tips

No doubt it's unlikely that the way I solved these dialog box tasks are identical to how you would have coded it. Although this code works, I'm sure as you put the Central components to the test you'll develop your own efficiencies. Here are just a few tips that may save you some time.

Choose Top-Left Registration

Use the top-left registration option when creating clips (as shown in Figure 6). At least when defining the linkage identifiers for the mDialogBox component, make sure your content bleeds down and to the right.

Although you might like another registration option, the top left is the one to use when creating content for components, including mDialogBox.

Figure 6. Although you might like another registration option, the top left is the one to use when creating content for components, including mDialogBox.

Don't Bother Learning the Hierarchy, Use Methods

In the exercises in this article I always "talked down" to the symbols contained in the dialog box. If you want to put code inside that "talks up" the hierarchy to the component itself (that is, the dialog box instance) then it's best to pass a reference to that component down when the dialog box opens or changes. Something like this right after you open the dialog box:

myDialog.getSelectedContent().theController=myDialog;

This way, from code inside the symbol embedded in the dialog box, you can just use theController.doClose() to close the dialog box.

An alternative, if less than ideal, way would be to do something like this:

theController=this._parent._parent;
doClose_btn.onRelease=function(){
   theController.doClose();
};

Although this works, it relies on a specific hierarchy that may change in future revisions of the components. Besides, Central components are stored in remote shared libraries and can be updated independent of your application.

Set Up a Local Testing Environment

Many people complain that you can't see anything you're doing while working on Central applications. That is, Test Movie doesn't work because you have to test inside the Central environment. I used to go through a number of hoops to test inside Flash; for example, I'd download a copy of CentralComponents.swf and change each component's linkage to point to the local copy (then change it back when I was ready to distribute it).

The thing is, with just a couple extra steps you can indeed test inside Central! Start by installing the first revision of your application from localhost or another real server. Hunt down where the SWFs were installed (for example, inside the folder "C:\Documents and Settings\Phillip\Application Data\Macromedia\Central") and then overwrite those files when you publish. All you have to do is set the filename and destination from the Publish Settings dialog box.

At first glance the mDialogBox component seems too simple to learn much about. However, it's actually pretty cool—and quite deep. The big lesson you should learn here is that there are even more gems hidden among other components in Central. The time invested to learn how they work will pay you back over time.